/*
 * SaleBO.java
 *
 * Created on March 5, 2007, 8:07 PM
 *
 * Stores information about a coupon, which is applied to a revenue source
 * contained on a transaction line.  This object contains the relevant
 * revenue source ID, the amount or percentage of the coupon, the start and
 * expiration dates, and a description of the coupon.
 */

package edu.byu.isys413.group1E.data;

import java.util.Calendar;
import java.util.Date;

/**
 *
 * @author tkulbeth
 */
public class SaleBO extends RevenueSourceBO {
    
    private int quantity;
    private ProductBO product;
    private boolean returnLine;
    
    /** Creates a new instance of SaleBO */
    SaleBO() {
        this.setReturnLine(false);
        this.setType("sale");
        this.setIsDirty(true);
    }
    
    /** Creates a new instance of TransactionBO with an ID*/
    SaleBO(String revSrcID) {
        this.setType("sale");
        setRevSrcID(revSrcID);
        this.setIsDirty(true);
    }

    /* Returns the sale quantity (if the coupon is for
     * a certain dollar amount discount).
     */
    /**
     * 
     * @return 
     */
    public int getQuantity() {
        return this.quantity;
    }
    
    /* Sets the coupon amount (if the coupon is for
     * a certain dollar amount discount).
     */
    /**
     * 
     * @param qty 
     */
    public void setQuantity(int qty) {
        setIsDirty(true);        
        this.quantity = qty;
        if(this.getProduct()!=null && this.getReturnLine()==false){
            this.setPrice(this.getProduct().getPrice()*qty);
        }
        if(this.getProduct()!=null && this.getReturnLine()==true){
            this.setPrice(-this.getProduct().getPrice()*qty);
        }
    }

    /**
     * 
     * @return 
     */
    public ProductBO getProduct() {
        return product;
    }

    /**
     * 
     * @param product 
     */
    public void setProduct(ProductBO product) {
        this.product = product;
        this.setIsDirty(true);
    }

    /**
     * 
     * @return 
     */
    public boolean getReturnLine() {
        return returnLine;
    }

    /**
     * 
     * @param returnLine 
     */
    public void setReturnLine(boolean returnLine) {
        this.returnLine = returnLine;
        this.setIsDirty(true);
    }
}
